package com.dev.stream.map;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 戴 骥
 * @date 2021-09-05 17:24
 */
public class FlatMap {
    @Test
    public void flatMap() {

        ////将两个字符数组合并成一个新的字符数组。
        List<String> listStr2 = Arrays.asList("m-k-l-a", "1-3-5-7");
        List<String> collect = listStr2.stream().flatMap(t -> {
            String[] split = t.split("-");
            return Arrays.stream(split);
        }).collect(Collectors.toList());
        System.out.println("collect = " + collect);

    }
}
